package cn.bfay.lion.jingdong.mq;

import cn.bfay.lion.jingdong.entity.ProductDetailInfo;
import cn.bfay.lion.jingdong.entity.ProductInfo;
import cn.bfay.lion.util.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * NoticeProducer.
 *
 * @author wangjiannan
 */
@Slf4j
@Component
public class NoticeProducer {
    @Resource
    private AmqpTemplate rabbitTemplate;
    @Value("${jingdong.product.discount.notice.queue}")
    private String noticeQueue;

    public void sendNotice(ProductDetailInfo productDetailInfo, ProductInfo productInfo) {
        log.debug("------------发送notice-----------------");
        String content = JsonUtils.bean2Json(productDetailInfo) + "|+|" + JsonUtils.bean2Json(productInfo);
        rabbitTemplate.convertAndSend(noticeQueue, content);
    }
}
